/*
 * Hidden Equity LLC
 * Author: Maksym Fedyay, Kyiv, mcsimf@gmail.com
 * Date: 29.02.2012
 */

package com.hiddenequity.geolocation_service;

import com.hiddenequity.utils.SOAPUtils;
import com.hiddenequity.utils.UrlBuncher;

public class GeoLocationService {
	
	public static final String URL_GEO_LACATION_SERVICE = UrlBuncher.URL_BASE + "GeoLocationService";
	
	
	/*
	 * Get geo data
	 */
	static public String getGeoLocationData(String countryCode, String companyName,
			String phoneNumber, String streetAddress, String streetAddress2,
			String cityName, String provinceName, String postalCode){
		
		String streetAddressTag = "";
		if(!streetAddress.equals("") && streetAddress != null)
			streetAddressTag = "<streetAddress>" + streetAddress +"</streetAddress>";
	
		String streetAddress2Tag = "";
		if(!streetAddress2.equals("") && streetAddress2 != null)
			streetAddress2Tag = "<streetAddress2>" + streetAddress2 + "</streetAddress2>";
		
		String cityNameTag = "";
		if(!cityName.equals("") && cityName != null)
			cityNameTag = "<cityName>" + cityName + "</cityName>";
		
		String postalCodeTag = "";
		if(!postalCode.equals("") && postalCode != null)
			postalCodeTag = "<postalCode>" + postalCode + "</postalCode>";
		
		String countryCodeTag = "";
		if(!countryCode.equals("") && countryCode != null)
			countryCodeTag = "<countryCode>" + countryCode + "</countryCode>";
		
		String provinceNameTag = "";
		if(!provinceName.equals("") && provinceName != null)
			provinceNameTag = "<provinceName>" + provinceName + "</provinceName>";

		String SOAPBody = 
				"<soap:Body>" +
						"<get>" +
							"<selector>" +
								"<addresses>" +
									streetAddressTag +
									streetAddress2Tag + 
									cityNameTag + 
									provinceNameTag +
									postalCodeTag +
									countryCodeTag +
								"</addresses>" +								
							"</selector>" +
						"</get>" +
				"</soap:Body>";		
		String envelope = SOAPUtils.buildEnvelope(SOAPBody);
		return envelope;
	}
	
}
